'use strict';
const got = require('got');

// to-do
const endpoint =
  'https://api.deezer.com/1.0/gateway.php?version=7.17.0&iap=1&output=3&buildId=ios9_universal&api_key=ZAIVAHCEISOHWAICUQUEXAEPICENGUAFAEZAIPHAELEEVAHPHUCUFONGUAPASUAY&screenHeight=480&input=3&sid=fr572298e2cf81027465d786446c602cfd088679&lang=en&network=cd1e23b89d4321385f025c861c0ac094b855c9acfdba0d9b352166a29e451159&mobile_tracking=eyJidW5kbGVfaWQiOiJjb20uZGVlemVyLkRlZXplciIsImlkZmEiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJhZGlkIjoiIn0=&screenWidth=320&method=user_create';

// we do not use this atm
const generateArl = async () => {
  try {
    const userDetails = await got('https://randomuser.me/api/', { responseType: 'json' });
    const user = userDetails.body.results[0];

    const arlDetails = await got(endpoint, {
      method: 'POST',
      responseType: 'json',
      headers: { 'User-Agent': 'User-Agent: Deezer/7.17.0.2 CFNetwork/1098.6 Darwin/19.0.0' },
      body: {
        BLOG_NAME: user.login.username,
        SEX: 'M',
        PASSWORD: '600d061b15c295e50227e9f936ce4cfd',
        LANG: 'en',
        EMAIL: user.email,
        BIRTHDAY: '1994-01-01',
      },
    });

    return { arl: arlDetails.body.results };
  } catch (e) {
    return e;
  }
};

module.exports = generateArl;
